package com.zbbt.sportslottery.util;



public class MoneyUtil {
	private static String string;
	private static long BILLION = 1 * 1000000000;// 1亿
	private static long SMOLLION = 100000000;

	public static String getMoneyChange(String money) {
		if (money.contains(",")) {
			String splitlong = money.replace(",", "").replace(" ", "").trim();
			if (splitlong.contains(".")) {
				String substring = splitlong.substring(0, splitlong.indexOf("."));
				long l = Long.parseLong(substring);
				if (l < BILLION) {
					double d = (double) l / SMOLLION;
					String valueOf = String.valueOf(d);
					String doubleValue = valueOf.substring(0, 4);
					string = doubleValue + "亿";
				} else if (l >= BILLION) {
					double val = (double) l / SMOLLION;
					String doublel = String.valueOf(val);
                    String format = doublel.substring(0, 5);
					string = format + "亿";
				}
			} 
		}
		return string;
	}

	public static String getMoneyChangeString(String money) {
		StringBuffer sb = new StringBuffer();
		if (money.contains(".")) {
			String money1 = money.substring(0, money.indexOf(".")).replace(",", "").replace(" ", "").trim();
			int length = money1.length();
			if (length > 8) {
				sb.append(money1.substring(0, length - 8));
				sb.append(".");
				sb.append(money1.substring(length - 8, length - 6));
				sb.append("亿");
				return sb.toString();
			} else if (length > 4) {
				sb.append(money1.substring(0, length - 4));
				sb.append("万");
				return sb.toString();
			} else {
				sb.append(money1 + "元");
				return sb.toString();
			}
		}
		return money;
	}
}
